package com.zwj.config.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zwj
 * @Description: 拦截器配置类
 * @date 2022/6/25 1:51 下午
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    /**
     * 注册拦截器
     * @param registry 拦截器注册器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/**")//指定要拦截的请求
                .excludePathPatterns("/user/login")//排除用户登录请求
                .excludePathPatterns("/swagger-ui.html")//排除Swagger UI页面
                .excludePathPatterns("/swagger-resources/**")//排除Swagger资源配置
                .excludePathPatterns("/v2/api-docs")//排除Swagger API文档
                .excludePathPatterns("/webjars/**");//排除Swagger相关静态资源
    }

}
